package com.sright.bcard.enterprise.web.controller;

import com.sright.bcard.common.service.share.dto.enterprise.MaterialDTO;
import com.sright.bcard.common.service.share.mvcresolver.EnableLoginAuth;
import com.sright.bcard.enterprise.share.service.MaterialService;
import com.sright.common.response.SrightResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/material")
public class MaterialController extends BaseController {

    @Autowired
    private MaterialService materialService;

    @GetMapping("/page.json")
    @EnableLoginAuth
    public SrightResponse materialList(MaterialDTO materialDTO) {
        materialDTO.setEnterpriseId(userContext.getEnterpriseId());
        return materialService.page(materialDTO);
    }

    @DeleteMapping("/delete.json")
    @EnableLoginAuth
    public SrightResponse delete(@RequestBody MaterialDTO materialDTO) {
        return SrightResponse.defaultSuccess(materialService.deleteMaterial(materialDTO.getId()));
    }

}
